package com.zjlab.sandtable.handler;

import cn.hutool.json.JSONUtil;
import com.zjlab.sandtable.bean.CoinsMakeStatusInfo;
import com.zjlab.sandtable.utils.RemoteCall;
import io.netty.channel.ChannelHandler;
import io.netty.channel.ChannelHandlerContext;
import io.netty.channel.SimpleChannelInboundHandler;
import lombok.extern.slf4j.Slf4j;
import org.springframework.stereotype.Component;

/**
 * @author xue
 * @create 2022-11-07 15:29
 */
@Slf4j
@Component
@ChannelHandler.Sharable
public class CoinsMakeStatusInfoHandler extends SimpleChannelInboundHandler<CoinsMakeStatusInfo> {

    @Override
    protected void channelRead0(ChannelHandlerContext ctx, CoinsMakeStatusInfo msg) throws Exception {
        log.info("收到制作完成指令：{}", msg);
        RemoteCall.postRestful(
                "/api/GK/SendMakingStatus",
                JSONUtil.createObj().set("state", msg.getStatus().equals(1)),
                500
        );
    }

}
